package com.xc.controller;

import com.xc.pojo.Floor;
import com.xc.pojo.Room;
import com.xc.service.FloorService;
import com.xc.service.RoomService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class IndexController {
    @Resource
    private FloorService floorService;

    @Resource
    private RoomService roomService;

    @RequestMapping("/index")
    public String index(Model model){
        //调用查询所有楼层的方法
        List<Floor> floorList = floorService.queryFloorList(null);
        //查询所有房间
        List<Room> roomList = roomService.queryRoomList(null);
        //将数据添加到model
        model.addAttribute("floorList",floorList);
        model.addAttribute("roomList",roomList);
        return "forward:/index.jsp";
    }

}
